package com.education.project.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.education.project.mapper.SysConfigMapper;
import com.education.project.model.SysConfig;
import com.education.project.service.SysConfigService;

@Service
public class SysConfigServiceImpl implements SysConfigService {
	@Autowired
	private SysConfigMapper sysConfigMapper;
	
	@Override
	public String getConfigValue(String configname) {
		String value = sysConfigMapper.getValue(configname);
		if(value!=null) {
			return value.trim();
		}
		return "";
	}

	@Override
	public List<SysConfig> getAllSysConfig() {
		return sysConfigMapper.getall();
	}

	@Override
	@Transactional
	public void saveSysConfig(SysConfig sysConfig) {
		sysConfigMapper.save(sysConfig);
	}

	@Override
	@Transactional
	public void updateSysConfig(SysConfig sysConfig) {
		sysConfigMapper.update(sysConfig);
	}

	@Override
	@Transactional
	public void deleteSysConfig(String configname) {
		sysConfigMapper.delete(configname);
	}

}
